The aim of the study was to construct a two-asset optimal investment portfolio using machine learning and macroeconomic data at monthly and quarterly intervals. The auxiliary objective was to identify which macroeconomic variables significantly impact the estimation of the S&P 500 stock index and the USD/GBP currency pair. The framework included two steps: firstly, time series forecasts were conducted using tree ensemble methods, namely the random forest and XGBoost, and secondly, the forecasts were used as expected values to construct the portfolios. We analyze the extent to which the structure of a portfolio based on the estimated data differs from the one built using historical data. The results of the research showed that it was possible to use the macroeconomic data to efficiently forecast the considered time series and construct an optimal investment portfolio.
random forest, ensemble model, XGBoost, portfolio optimization
G11, G17
Abreu, G., Neves, R., & Horta, N. (2018). Currency exchange prediction using machine learning, genetic algorithms and technical analysis. https://doi.org/10.48550/arXiv.1805.11232.
Ahmed, N. K., Atiya, A. F., El Gayar, N., & El-Shishiny, H. (2010). An empirical comparison of machine learning models for time series forecasting. Econometric Reviews, 29(5–6), 594–621. https://doi.org/10.1080/07474938.2010.481556.
Baasher, A. A., & Fakhr, M. W. (2011). FOREX Trend Classification using Machine Learning Techniques. In A. Zaharim, K. Sopian, N. Mastorakis & V. Mladenov (Eds.), ACS'11: Proceedings of the 11th WSEAS International Conference on Applied Computer Science (pp. 41–47). World Scientific and Engineering Academy and Society. https://www.wseas.us/e-library/conferences/2011/Penang/ACRE/ACRE-05.pdf.
Basak, S., Kar, S., Saha, S., Khaidem, L., & Dey, S. R. (2019). Predicting the direction of stock market prices using tree-based classifiers. The North American Journal of Economics and Finance, 47, 552–567. https://doi.org/10.1016/j.najef.2018.06.013.
Boyoukliev, I. V., Kulina, H. N., & Gocheva-Ilieva, S. G. (2022). Modelling and Forecasting of EUR/USD Exchange Rate Using Ensemble Learning Approach. Cybernetics and Information Technologies, 22(4), 142–151. https://doi.org/10.2478/cait-2022-0044.
Cabrera Malik, S. (2024). Is xgboost immune to multicolinearity?. https://medium.com /@sebastian.cabrera-malik/is-xgboost-inmune-to-multicolinearity-4dd9978605b7 .
Charteris, A., & McCullough, K. (2020). Tracking error vs tracking difference: Does it matter? Investment Analysts Journal, 49(3), 269–287. https://doi.org/10.1080/10293523.2020.1806480.
Choi, J. (2021). Maximum Drawdown, Recovery, and Momentum. Journal of Risk and Financial Management, 14(11), 1–25. https://doi.org/10.3390/jrfm14110542.
Choudhry, R., & Garg, K. (2008). A Hybrid Machine Learning System for Stock Market Forecasting. Proceedings of World Academy of Science, Engineering and Technology, 29, 315–318. https://par.cse.nsysu.edu.tw/resource/paper/2008/080820/A%20Hybrid%20Machine%20Learning%20System%20for%20Stock%20Market%20Forecasting.pdf.
Géron, A. (2022). Hands-On Machine Learning with Scikit-Learn, Keras & TensorFlow. O’Reilly Media.
Gregorutti, B., Michel, B., & Saint-Pierre, P. (2017). Correlation and variable importance in random forests. Statistics and Computing, 27(3), 659–678. https://doi.org/10.1007/s11222-016-9646-1.
Hegazy, O., Soliman, O. S., & Salam, M. A. (2014). A Machine Learning Model for Stock Market Prediction. https://doi.org/10.48550/arXiv.1402.7351.
Kaszuba, B. (2011). Praktyczne problemy w teorii portfela. Prace Naukowe Uniwersytetu Ekonomicznego we Wrocławiu, (174), 381–393.
Kaushik, M., & Giri, A. K. (2020). Forecasting Foreign Exchange Rate: A Multivariate Comparative Analysis between Traditional Econometric, Contemporary Machine Learning & Deep Learning Techniques. https://doi.org/10.48550/arXiv.2002.10247.
Król-Nowak, A., & Kotarba, K. (2022). Podstawy uczenia maszynowego. Wydawnictwa Akademii Górniczo-Hutniczej im. Stanisława Staszica w Krakowie. https://winntbg.bg.agh.edu.pl/skrypty4/0599/podstawy_uczenia.pdf.
Leippold, M., Wang, Q., & Zhou, W. (2022). Machine learning in the Chinese stock market. Journal of Financial Economics, 145(2A), 64–82. https://doi.org/10.1016/j.jfineco.2021.08.017.
Liu, Y. (2023). Government debt and risk premia. Journal of Monetary Economics, 136, 18–34. https://doi.org/10.1016/j.jmoneco.2023.01.009.
Loh, L. K. Y., Kueh, H. K., Parikh, N. J., Chan, H., Ho, N. J. H., & Chua, M. C. H. (2022). An Ensembling Architecture Incorporating Machine Learning Models and Genetic Algorithm Optimization for Forex Trading. FinTech, 1(2), 100–124. https://doi.org/10.3390/fintech1020008.
Łuniewska, M. (2012). Ekonometria finansowa. Analiza rynku kapitałowego. Wydawnictwo Naukowe PWN.
Mabrouk, N., Chihab, M., & Chihab, Y. (2022). A Trading Strategy in the Forex Market based on Linear and Non-linear Machine Learning Algorithms. https://www.scitepress.org/Papers/2021/107288/107288.pdf.
Magdon-Ismail, M., & Atiya, A. F. (2004). Maximum Drawdown. Risk Magazine, 17(10), 99–102.
Markowitz, H. (1952). Portfolio Selection. The Journal of Finance, 7(1), 77–91. https://doi.org/10.2307/2975974.
Matuszewska-Janica, A., & Witkowska, D. (2008). Modelowanie kursu euro/dolar: dynamiczne modele ekonometryczne i sztuczne sieci neuronowe. Zeszyty Naukowe SGGW – Ekonomika i Organizacja Gospodarki Żywnościowej, (69), 55–75. https://doi.org/10.22630/EIOGZ.2008.69.92.
Maung, K., & Swanson, N. R. (2025). A survey of models and methods used for forecasting when investing in financial markets. International Journal of Forecasting, 41(4), 1355–1382. https://doi.org/10.1016/j.ijforecast.2025.03.002.
Nabipour, M., Nayyeri, P., Jabani, H., Mosavi, A., Salwana, E., & Shahab, S. (2020a). Deep Learning for Stock Market Prediction. Entropy, 22(8), 1–23. https://doi.org/10.3390/e22080840.
Nabipour, M., Nayyeri, P., Jabani, H., Shahab, S., & Mosavi, A. (2020b). Predicting Stock Market Trends Using Machine Learning and Deep Learning Algorithms Via Continuous and Binary Data; a Comparative Analysis. IEEE Access, 8, 150199–150212. https://doi.org/10.1109/ACCESS.2020.3015966.
Patel, J., Shah, S., Thakkar, P., & Kotecha, K. (2015). Predicting stock market index using fusion of machine learning techniques. Expert Systems with Applications, 42(4), 2162–2172. https://doi.org/10.1016/j.eswa.2014.10.031.
Pham, N., Cui, B., & Ruthbah, U. (2025). The Performance of the 60/40 Portfolio: A Historical Perspective. https://rpc.cfainstitute.org/research/reports/2025/performance-of-the-60-40-portfolio.
Qi, L., Khushi, M., & Poon, J. (2020). Event-Driven LSTM for Forex Price Prediction. 2020 IEEE Asia-Pacific Conference on Computer Science and Data Engineering (CSDE), Australia, 1–6. https://doi.org/10.1109/CSDE50874.2020.9411540.
Reddy, V. K. S. (2018). Stock Market Prediction Using Machine Learning. International Research Journal of Engineering and Technology, 5(10), 1032–1035. https://www.irjet.net/archives/V5/i10 /IRJET-V5I10193.pdf .
Roßbach, P. (2018). Neural Networks vs. Random Forests – Does it always have to be Deep Learning. https://blog.frankfurt-school.de/wp-content/uploads/2018/10/Neural-Networks-vs-Random-Forests.pdf.
Roy, M.-H., & Larocque, D. (2012). Robustness of random forests for regression. Journal of Nonparametric Statistics, 24(4), 993–1006. https://doi.org/10.1080/10485252.2012.715161.
Sharpe, W. F. (1966). Mutual Fund Performance. The Journal of Business, 39(1), 119–138.
Sharpe, W. F. (1998). The Sharpe ratio. In P. L. Bernstein & F. J. Fabozzi (Eds.), Streetwise. The Best of The Journal of Portfolio Management (pp. 169–178). Princeton University Press. https://doi.org/10.2307/j.ctv1mjqtwg.24.
Shen, S., Jiang, H., & Zhang, T. (2012). Stock Market Forecasting Using Machine Learning Algorithms. Stanford University.
Tang, Y., Song, Z., Zhu, Y., Yuan, H., Hou, M., Ji, J., Tnag, C., & Li, J. (2022). A survey on machine learning models for financial time series forecasting. Neurocomputing, 512, 363–380. https://doi.org/10.1016/j.neucom.2022.09.003.
Ţiţan, A. G. (2015). The Efficient Market Hypothesis: review of specialized literature and empirical research. Procedia Economics and Finance, 32, 442–449. https://doi.org/10.1016/S2212-5671(15)01416-1.
Wong, A., Whang, S., Sagre, E., Sachin, N., Dutra, G., Lim, Y. W., Hains, G, Khmelevsky, Y., & Zhang, F. C. (2023, December). Short-term stock price forecasting using exogenous variables and machine learning algorithms [paper presentation]. 3rd International Conference on Intelligent Cybernetics Technology & Applications (ICICyTA), Denpasar, Indonesia. https://doi.org/10.1109/ICICyTA60173.2023.10428814.
Zhong, X., & Enke, D. (2019). Predicting the daily return direction of the stock market using hybrid machine learning algorithms. Financial Innovation, 5(1), 1–20. https://doi.org/10.1186/s40854-019-0138-0.